package com.jblv.frame.common.utils;


import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;

/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title ModelMapperUtils
 * @projectName jblv-frame
 * @packageName com.jblv.frame.common.utils
 * @description ModelMapperUtils
 * @date Create at 2020/5/20 10:43
 * @since jdk1.8
 */
public class ModelMapperUtils {
    private static ModelMapper modelMapper = new ModelMapper();

    public ModelMapperUtils() {
    }

    public static <T> T map(Object source, Class<T> destinationType) {
        return source == null ? null : modelMapper.map(source, destinationType);
    }

    public static void map(Object source, Object destination) {
        if (source != null) {
            modelMapper.map(source, destination);
        }
    }

    static {
        modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    }
}
